import { useState, useDebugValue } from "react";

const useTodoList = () => {
  useDebugValue("todolist");

  const [list, setList] = useState([{ id: 1, name: "zhangsan" }]);
  const [value, setValue] = useState("");
  const handleChange = (e) => {
    setValue(e.target.value);
  };
  const push = () => {
    setList((v) => [...v, { id: new Date().getTime(), name: value }]);
    setValue("");
  };

  return [list, value, handleChange, push];
};

export default useTodoList;
